# name : proportion.delta.mdd
# key: prop.delta.mdd
# key: prop.diff.mdd
# contributor: Shuguang Sun
# --
${1:deltamdd} <- function(ratio = 1, p1 = 0.15, p2 = 0.1, delta0 = 0,
                          alpha = 0.025, sided = 1, n = 200) {
  c <- 1/(1 + ratio)
  if (is.null(delta0)) {
      delta0 <- 0
  }
  zalpha <- -stats::qnorm(alpha/sided)
  deltaHat <- zalpha * sqrt(p1*(1-p1)/ratio + p2*(1-p2)) / sqrt(n/(1+ratio)) + delta0
  deltaHat
}
$1(p1 = ${2:0.15}, p2 = ${3:0.1}, n = ${4:100})
